package lib

func init() {
	Probs = append(Probs, Problem{
		Num:         118,
		Discription: "生成杨辉三角的n行",
		Level:       1,
		Labels: map[string]int{
			"动态规划": 1,
		},
	})
}

func Generate(numRows int) [][]int {
	res := [][]int{{1}}
	for i := 1; i < numRows; i++ {
		col := make([]int, i+1)
		col[0] = 1
		col[i] = 1
		//上界是i，不是numRows
		for j := 1; j < i; j++ {
			col[j] = res[i-1][j-1] + res[i-1][j]
		}
		res = append(res, col)
	}

	return res
}
